package com.zrm.zfcrpa.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

@EnableAsync
@Configuration
public class TheadPoolTaskConfig {

    private int corePoolSize = 10;

    private int maxPoolSize = 200;

    private int queueCaoacity = 10;

    private String ThreadNamePrefix = "asyncExecutor-";

    @Bean
    public Executor asyncExecutor(){
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(corePoolSize);
        executor.setMaxPoolSize(maxPoolSize);
        executor.setQueueCapacity(queueCaoacity);
        executor.setThreadNamePrefix(ThreadNamePrefix);
        return executor;
    }

}
